package com.itboye.shop.me;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.shop.R;
import com.itboye.shop.base.BaseActivity;
import com.itboye.shop.logincontroller.LoginController;
import com.itboye.shop.logincontroller.UnLoginState;
import com.itboye.shop.util.loadutil.Const;
import com.itboye.shop.util.loadutil.SPUtils;

/**
 * 设置
 */
public class ActivitySetUp extends BaseActivity {
    TextView tvTitle;
    ImageView back;
    Button tuichu_ok;
    private TextView tvEdition;//当前版本
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set_up);

        tvTitle.setText("设置");

        try {
            // 获取packagemanager的实例
            PackageManager packageManager = getPackageManager();
            // getPackageName()是你当前类的包名，0代表是获取版本信息
            PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(),0);
            String version = packInfo.versionName;

            tvEdition.setText(version);
        } catch (Exception e) {
        }
    }

    @Override
    public void onClick(View view) {
        Intent intent = null;
        switch (view.getId()) {
            case R.id.back:
                finish();
                break;
            case R.id.tuichu_ok:
                onEdit();
                finish();
                break;
        }
    }

    public void  onEdit(){
        LoginController.setLoginState(new UnLoginState());
//        MyApplication.getInstance().mPushAgent.removeAlias(
//                SPUtils.get(this, null, Const.ID, "") + "", "htb",
//                new UTrack.ICallBack() {
//
//                    @Override
//                    public void onMessage(boolean arg0, String arg1) {
//                        // TODO Auto-generated method stub
//                        System.out.println("---退出登录>"+arg0+"---"+arg1);
//                    }
//                });
        SPUtils.put(this, null, Const.ID, "");
        SPUtils.put(this, null, Const.USERNAME, "");
        SPUtils.put(this, null, Const.PASSWORD, "");
        SPUtils.put(this, null, Const.MOBILE, "");
        SPUtils.put(this, null, Const.IS_LOGINED, false);
        SPUtils.put(this, null, Const.HEAD, "");
        SPUtils.put(this, null, Const.NICK, "");
        SPUtils.put(this, null, Const.PaySecret, "");
        SPUtils.put(this, null, Const.S_ID, "");
        Intent intent=new Intent("EXITCHANGE");
        sendBroadcast(intent);

    }
}
